package com.woniuxy.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.woniuxy.system.entity.DataRecord;
import com.woniuxy.system.entity.PerformancePost;
import com.woniuxy.system.mapper.DataRecordMapper;
import com.woniuxy.system.mapper.PerformancePostMapper;
import com.woniuxy.system.service.PerformancePostService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * <p>
 * 岗位管理 服务实现类
 * </p>
 *
 * @author woniuxy
 * @since 2022-06-01
 */
@Service
public class PerformancePostServiceImpl extends ServiceImpl<PerformancePostMapper, PerformancePost> implements PerformancePostService {
    @Autowired
    DataRecordMapper dataRecordMapper;

    @Autowired
    PerformancePostMapper performancePostMapper;

    @Override
    public boolean addPerformancePost(PerformancePost performancePost,String userid) {
        DataRecord dataRecord=new DataRecord();
        dataRecord.setCreateTime(new Date());
        dataRecord.setInfo("新建岗位管理");
        dataRecord.setUserId(Long.valueOf(userid));
        int insert=dataRecordMapper.insert(dataRecord);
        System.out.println("datarecordeId="+dataRecord.getId());
        performancePost.setRecordId(dataRecord.getId());
        int insert1=performancePostMapper.insert(performancePost);
        if (insert==1&&insert1==1){
            return true;
        }
        return false;
    }

    @Override
    public Page<PerformancePost> getAllPerformancePost(IPage<PerformancePost> page, Wrapper<PerformancePost> wrapper) {
        return performancePostMapper.getAllPerformancePost(page,wrapper);
    }

    @Override
    public List<PerformancePost> getPerformancePostTree() {
        return performancePostMapper.getPerformancePostTree();
    }
}
